<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="s" uri="/struts-tags"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String annexType = request.getParameter("annexType");
String codeId =request.getParameter("codeId");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
  <head>
  	<base target="_self"/>
    <title>证书修改</title>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <link rel="stylesheet" type="text/css" href="../commission/css/form.css" />
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath() %>/jqGrid/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/js/base/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
        <c:if test="${requestScope.message!=null}">
			<script type="text/javascript">
  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
  	 		     window.returnValue="success";
  	 		      <c:if test="${requestScope.type==0}">
 		    	  	window.close();
 		    	  </c:if>
  	 		     
  			</script>
	    </c:if>
<%--	    <script type="text/javascript">--%>
<%--	         var api = frameElement.api;--%>
<%--	         if (api!=undefined)--%>
<%--	         {--%>
<%--	         	var W = api.opener;--%>
<%--	         }--%>
<%--        </script>--%>
    <script type="text/javascript">

    $(document).ready(function() {
    	operator = "${requestScope.operator}";
	    
	});	
    function saves(){
    	    if($("#cerifyNo").val()=="")
		    {
			      alert("请填写证书编号!");
			      $("#cerifyNo").focus();
			      return false;
		    }else if(!checkExp($("#cerifyNo").val())){
				alert("证书编号不能含有如下特殊符号：\" # $ \, \'");
				$("#cerifyNo").focus();
				return false;
			}else if(!cerifyNoCountintlen($("#cerifyNo").val())){
				alert("证书编号最多为40个字符,字符输入超出限制!");
				$("#cerifyNo").focus();
				return false;
			}
    		if($("#cerifyName").val()=="")
		    {
			      alert("请填写证书名称!");
			      $("#cerifyName").focus();
			      return false;
		    }else if(!checkExp($("#cerifyName").val())){
				alert("证书名称不能含有如下特殊符号：\" # $ \, \'");
				$("#cerifyName").focus();
				return false;
			}else if(!cerifyNameCountintlen($("#cerifyName").val())){
				alert("证书名称最多为40个字符,字符输入超出限制!");
				$("#cerifyName").focus();
				return false;
			}
			
			
		    
    		if($("#cerifyOverdate").val()=="")
		    {
			      alert("请填写证书有效期!");
			      $("#cerifyOverdate").focus();
			      return false;
		    }else if(!checkNumber($("#cerifyOverdate").val())){
				alert("证书有效期格式不正确!");
				$("#cerifyOverdate").focus();
				return false;
			}else if(!cerifyOverdateCountintlen($("#cerifyOverdate").val())){
				alert("证书有效期最多为40个字符,字符输入超出限制!");
				$("#cerifyOverdate").focus();
				return false;
			}
		    
    		if($("#cerifyDate").val()=="")
		    {
			      alert("请填写证书获取时间!");
			      $("#cerifyDate").focus();
			      return false;
		    }
    		if(!checkExp($("#cerifyDesc").val())){
					alert("证书说明不能含有如下特殊符号：\" # $ \, \'");
					$("#cerifyDesc").focus();
					return false;
			}else if(!cerifyDescCountintlen($("#cerifyDesc").val())){
				alert("证书说明最多为250个字符,字符输入超出限制!");
				$("#cerifyDesc").focus();
				return false;
			}
		var xianZhi= "image/gif,image/GIF,image/jpeg,image/JPEG,image/png,image/PNG,image/jpg,image/JPG,image/bmp,image/BMP,application/zip,application/ZIP,application/rar,application/RAR,application/doc,application/DOC,application/docx,application/DOCX,application/xlsx,application/XLSX,application/xls,application/XLS,text/xml,text/XML,text/txt,text/TXT,application/msword,application/MSWORD,application/ppt,application/PPT,application/msexcel,application/MSEXCEL,application/pdf,application/PDF,text/plain,text/html,text/HTML,image/pjpeg,image/PJPEG";
		var filev =  document.getElementById("upFile").value;
		if(filev!=""){
			  var index = filev.lastIndexOf(".");
              var arr = filev.substring(index*1+1,filev.length);
              if(xianZhi.indexOf(arr) > -1){
            	    var cerifyNo= document.getElementById("cerifyNo").value;
					var cerifyName= document.getElementById("cerifyName").value;
					var cerifyDate= document.getElementById("cerifyDate").value;
					var cerifyDesc= document.getElementById("cerifyDesc").value;
					var cerifyOverdate = document.getElementById("cerifyOverdate").value;
					
					document.pageFrom.encoding = "multipart/form-data";
					document.pageFrom.action = "<%=request.getContextPath() %>/system/updateCerify1.action?cerifyDate="+cerifyDate+"&cerifyNo="+encodeURIComponent(encodeURIComponent(cerifyNo))+"&cerifyName="+cerifyName+"&cerifyDesc="+cerifyDesc+"&cerifyOverdate="+cerifyOverdate+"&userId=<%=request.getParameter("userId")%>&id=${sysCerify.id}";
	  				document.pageFrom.submit();
	  		  }else{
			      alert("该文件类型不允许上传，请上传doc、docx、xlsx、xls、gif、jpg、jpeg、png、bmp、zip、rar等类型的文件，当前文件类型为"+arr);
		      }
		}else{
			document.pageFrom.encoding = "multipart/form-data";
			document.pageFrom.action = "<%=request.getContextPath() %>/user/updateCerify2.action?userId=<%=request.getParameter("userId")%>&id=${sysCerify.id}";
			document.pageFrom.submit();
			//W.refreshIt();
		}
			
	}
    function selectFile(){
			   var cerifyPath = $("#cerifyPath").val();
			   window.location.href="download.action?filePath="+escape(encodeURIComponent(cerifyPath))+"&id=${sysCerify.id}";
	}
    //过滤表单的前后空格
		function trimkeyup(e) {
		     lucene_objInput = $(this);
		     if (e.keyCode != 38 && e.keyCode != 40 && e.keyCode != 13) {
		        var im = $.trim(lucene_objInput.val());
		       lucene_objInput.val(im); 
		    }
		} 
		//验证特殊字符
			function checkExp(inputData){ 
				//var regEx = new RegExp(/^(([^\^\.<>%&',:;=?$"'#@!~\]\[{}【】￥（）！·‘’”“。，、？：；—|\/\\/`\|])*)$/);
				var regEx = new RegExp(/^(([^$,"'#])*)$/);
				var result = inputData.match(regEx);
				if (result == null) {
				return false;
				}
				return true;
			}
    //数量验证
		function checkNumber(inputData){
			var flag = true; 
			var regEx = new RegExp( /^\d+\.{0,1}\d*$/);  
			var result = inputData.match(regEx);
			if(result == null){
				return false;
			}
			return true;
		 }
		//验证特殊字符
		function checkExp(inputData){ 
			var regEx = new RegExp(/^(([^$,"'#])*)$/);
			//var regEx = new RegExp(/^(([^\^\.<>%&',:;=?$"'#@!~\]\[{}【】￥（）！·‘’”“。，、？：；—|\/\\/`\|])*)$/);
			var result = inputData.match(regEx);
			if (result == null) {
				return false;
			}
			return true;
		}
		//内容过多的限制
	    function cerifyNoCountintlen(input){
			var result = $("#cerifyNo").val().length;
			if (result > 40) {
				return false;
			}else{
				return true;
			}
		}

		//内容过多的限制
	    function cerifyNameCountintlen(input){
			var result = $("#cerifyName").val().length;
			if (result > 40) {
				return false;
			}else{
				return true;
			}
		}
		//内容过多的限制
	    function cerifyDescCountintlen(input){
			var result = $("#cerifyDesc").val().length;
			if (result > 250) {
				return false;
			}else{
				return true;
			}
		}
		//内容过多的限制
	    function cerifyOverdateCountintlen(input){
			var result = $("#cerifyOverdate").val().length;
			if (result > 40) {
				return false;
			}else{
				return true;
			}
		}
    </script>
   <style type="text/css">
 		body{
 			background:#ffffff; background-image:url(images/);
 		}
   		html{
		    overflow-x: hidden;
			overflow-y: hidden;
		}  		
   </style>
  </head>
   <body class="fontbody" >
		<form action='' id="pageFrom"  method="post" enctype="multipart/form-data"  name="pageFrom"> 
		 <input type="hidden" name="id" value="${sysCerify.id}"></input>   
		<table border="0" cellpadding="4" width="100%"  cellspacing="1"  align="center" class="formTableNew">	

					<tr>
						<td align="right">
							证书编号：
						</td>
						<td align="left">
							<div class="div">
				            	<s:if test="sysCerify.cerifyNo != null "><input type='text' name='sysCerify.cerifyNo' id='cerifyNo'  value="${sysCerify.cerifyNo}"  style="width:205.8px;"></input>
				            	</s:if>
				            	<s:else><input type='text' name='sysCerify.cerifyNo' id='cerifyNo'  value="${sysCerify.cerifyNo}"  style="width:205.8px;"></input>
				            	</s:else>
				            	<img src="<%=request.getContextPath() %>/images/xh.png"></img>
							</div>
						</td>
					</tr>     
					<tr>
						<td align="right">
							证书名称：
						</td>
						<td align="left">
							<div class="div">
				            
						<s:if test="sysCerify.cerifyName != null "><input type='text' name='sysCerify.cerifyName' id='cerifyName'  value="${sysCerify.cerifyName}"  style="width:205.8px;"></input>
				            	</s:if>
				            	<s:else><input type='text' name='sysCerify.cerifyName' id='cerifyName'  value="${sysCerify.cerifyName}"  style="width:205.8px;"></input>
				            	</s:else>
				            	<img src="<%=request.getContextPath() %>/images/xh.png"></img>
							</div>
						</td>
					</tr>     
					
					<tr>
						<td align="right">
							证书选择：
						</td>
						<td align="left">
							<div class="div">
							        <input type="hidden" id="cerifyPath" name='sysCerify.cerifyPath' value="<s:property value='sysCerify.cerifyPath'/>"/>
							         <input type="hidden" id="cerifyType" name='sysCerify.cerifyType' value="<s:property value='sysCerify.cerifyType'/>"/>
								<a href="#" onclick="selectFile()"/><s:property value='sysCerify.cerifyPath'/></a></br>
								<input type="file" id="upFile" name="upload" style="width:55.4%;"/>
								<img src="<%=request.getContextPath() %>/images/xh.png"></img>
							</div>
						</td>
					</tr>	    
					<tr>
						<td align="right">
							证书有效期：
						</td>
						<td align="left">
							<div class="div">

						<s:if test="sysCerify.cerifyOverdate != null "><input type='text' name='sysCerify.cerifyOverdate' id='cerifyOverdate'  value="${sysCerify.cerifyOverdate}"  style="width:205.8px;"></input>
				            	</s:if>
				            	<s:else><input type='text' name='sysCerify.cerifyOverdate' id='cerifyOverdate'  value="${sysCerify.cerifyOverdate}"  style="width:205.8px;"></input>
				            	</s:else>
				            	<img src="<%=request.getContextPath() %>/images/xh.png"></img>年
							</div>
						</td>
					</tr>     
					<tr>
						<td align="right">
							证书获取时间：
						</td>
						<td align="left">
							<div class="div">
								<s:if test="sysCerify.cerifyDate != null "><input type='text' name='sysCerify.cerifyDate' id='cerifyDate'  value="${sysCerify.cerifyDate}" class='Wdate' onClick='WdatePicker();' style="width:205.8px;"></input>
				            	</s:if>
				            	<s:else><input type='text' name='sysCerify.cerifyDate' id='cerifyDate'  value="${sysCerify.cerifyDate}" class='Wdate' onClick='WdatePicker();' style="width:205.8px;"></input>
				            	</s:else>
				            	<img src="<%=request.getContextPath() %>/images/xh.png"></img>
							</div>
						</td>
					</tr> 
					<tr>
						<td align="right">
							证书说明：
						</td>
						<td align="left">
							<div class="div">
								<s:if test="sysCerify.cerifyDesc != null "><textarea rows="4" cols="10" name='sysCerify.cerifyDesc' id='cerifyDesc'    style="width:205.8px;">${sysCerify.cerifyDesc}</textarea>
								</s:if>
								<s:else><textarea rows="4" cols="10" name='sysCerify.cerifyDesc' id='cerifyDesc'    style="width:205.8px;">${sysCerify.cerifyDesc}</textarea>
								</s:else>
							</div>	
						</td>
					</tr>	
					<tr>
						 <td colspan="2" style="text-align:center;height:20px;font-size:15px;font-weight:bold;">
						 	<%if(!"view".equals(request.getParameter("operator"))){
							%>
							<input  type="button" onclick="saves()" value="保存" class="form_bt_orange" />
							<%}%>
						</td>
					</tr>
				</table>		
		</form>
	</body>
</html>
